package com.zzw.mvvm.viewmodels.demo;

import com.zzw.mvvm.base.BaseViewModel;
import com.zzw.mvvm.beans.DemoEntity;

import java.util.ArrayList;
import java.util.List;

import androidx.lifecycle.MutableLiveData;

public class RecycleDemoViewModel extends BaseViewModel {
    MutableLiveData<List<DemoEntity>> listDemo;
    List<DemoEntity> list=new ArrayList<>();
    public MutableLiveData<List<DemoEntity>> getListDemo() {
        if (listDemo==null){
            listDemo=new MutableLiveData<>();
        }
        return listDemo;
    }

    public void setListDemo(MutableLiveData<List<DemoEntity>> listDemo) {
        this.listDemo = listDemo;
    }

    public void update(){
        for (int i=0;i<10;i++){
            list.add(new DemoEntity("zz-------"+i,"age"));
        }
        listDemo.setValue(list);
    }
    public void clearList(){
        list.clear();
        listDemo.setValue(list);
    }

}
